package com.aquarium.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

import com.aquarium.R;
import com.aquarium.alarm.AlarmManager;

public class AlarmDialogActivity extends Activity {
	AlarmManager alarmManager;
	Button mButton;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub

		super.onCreate(savedInstanceState);
		Intent intent = getIntent();

		String[] strings = intent.getStringArrayExtra(AlarmManager.INFO);
		for (int i = 0; i < strings.length; i++) {
			Log.d("", i + "" + strings[i]);
		}
		setContentView(R.layout.alarm_dialog);
		ListView listView = (ListView) findViewById(R.id.listView1);
		listView.setAdapter(new ArrayAdapter<String>(this,
			R.layout.alarm_dialog_item, strings));
		alarmManager = AlarmManager.getInstance(this);
		if (alarmManager.isRangEnable()) {
			alarmManager.rang();
		}

		mButton = (Button) findViewById(R.id.button);
		mButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
//				alarmManager.closeRang();
				finish();
			}
		});

	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		alarmManager.closeRang();
	}
}
